package com.lmabbe.tenant.controller;

import com.lmabbe.common.global.constant.SysParamConstant;
import com.lmabbe.common.global.context.LmabbeMetadata;
import com.lmabbe.common.global.result.R;
import com.lmabbe.common.mvc.core.qiniu.AccessTokenHandler;
import com.lmabbe.tenant.objects.vo.OssAccessTokenVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lmabbe
 */
@RestController
@RequestMapping("oss")
public class OssController {

    @Autowired
    private AccessTokenHandler accessTokenHandler;
    @Autowired
    private LmabbeMetadata lmabbeMetadata;


    @GetMapping("accessToken")
    public R accessToken() {
        return R.success(new OssAccessTokenVO()
                .setAccessToken(accessTokenHandler.getAccessToken())
                .setUploadUrl(lmabbeMetadata.getParamByKey(SysParamConstant.SYS_OSS_HOST))
                .setCallbackUrl(lmabbeMetadata.getParamByKey(SysParamConstant.SYS_OSS_CALLBACK)));
    }
}
